#include<iostream>
//模板实现单例
template<typename T>
class Singleton//父类用到子类函数用奇异递归
{
public:
 static T&getInstance()
    {
        static T instance;
        return instance;
    }

};
class Test:public Singleton<Test>
{
public:
    //为了让父类能够构建子类对象
    friend  Singleton<Test>;
    void show()
    {
        std::cout<<"helloworld\n";
    }
private:
    Test(){}

};
int main()
{
    Test::getInstance().show();
    return 0;
}